<?php 
    include "top.php"; 
    include "../util.php";

    if ($_REQUEST['action'] == 'del') {
        $banners = $_REQUEST['banner'];
        $sql = sprintf('update banner set enabled = 0 where `id` in (%s)', implode(',', $banners));
        $result = mysql_query($sql);
        if (mysql_affected_rows() > 0) {
            Util::jsAlert('刪除成功', 'banner.php');
        }
    }
?>
      <div id="top-3">
        <div id="m-text-1">
            <ul>
                <li>系統管理功能</li>
                <li><a href="admin_manage.php">管理管理員</a></li>
                <li><a href="banner.php">管理首頁圖片</a></li>
            </ul>
        </div>
	 
	 
        <div id="m-text-2_banner">
          <ul>
           
            <li> / </li>
            <li><a href="banner_add.php">新增</a></li>
            <li>首页图片管理</li>
          </ul>
        </div>
		
		<div id="m-text-2">
 
<script type="text/javascript">
$(function() {
    $('form[name="banner_form"]').submit(function() {
        if ($(this).find('input:checked[name="banner[]"]').length == 0) {
            alert('請選擇需要刪除的首頁圖片');
            return false;
        }
        return confirm("確定要刪除選擇的訊息嗎？一旦刪除將不能恢複！");
    });

    $('#chk_all').change(function() {
        var _elems = $(this).closest('form').find('input[name="banner[]"]');
        var _checked = $(this).attr('checked');
        _elems.each(function(){
            if (_checked == true) {
                $(this).attr('checked', 'checked');
            }else{
                $(this).removeAttr('checked');
            }
	    });
    });
});
</script>


            <form name="banner_form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?action=del">

    <?php 
        /*$webname="product";	
        $title2=make_safe($_GET["title"]);
       if($page){
        $page_size=10;
        $sql="select count(*) as total from ".$webname." where nid='$nid' ";
        if($BigClassName!=""){$sql=$sql." and BigClassName='$BigClassName'";}
        if($SmallClassName!=""){$sql=$sql." and SmallClassName='$SmallClassName'";}
        if($title2!=""){$sql=$sql." and title like '%".$title2."%'";}
        $result=mysql_query($sql);
        $message_count=mysql_result($result,0,"total");
        $page_count=ceil($message_count/$page_size);	
        $offset=($page-1)*$page_size;	
        $sql="select * from ".$webname." where nid='$nid' ";
        if($BigClassName!=""){ $sql=$sql."and BigClassName='$BigClassName'";}
        if($SmallClassName!=""){$sql=$sql." and SmallClassName='$SmallClassName'";}
        if($title2!=""){$sql=$sql." and title like '%".$title2."%'";}
        $sql=$sql."order by id desc limit $offset, $page_size";
        $result=mysql_query($sql);
        while ($row=mysql_fetch_object($result)){
        
              $aa=getimagesize("../".$row->images);
    $weight=$aa["0"];////获取图片的宽
    $height=$aa["1"];///获取图片的高

    if($weight>=$height){$weight1=160;$height1=160*$height/$weight;}
    if($height>=$weight){$height1=160;$weight1=160*$weight/$height;} */
       
            $sql = "select * from banner where enabled = 1 order by sort_index";
            $result = mysql_query($sql);
            while ($banner = mysql_fetch_assoc($result)) {
        ?>
                <table border="0" cellpadding="0" cellspacing="0" class="album_photo">
                  <tr>
                    <td class="photo">
                        <img src="<?php echo "../".$banner['images'];?>" height="160" border="0" />
                    </td>
                  </tr>
                  <tr>
                    <td class="photo-txt">
                        <input name="banner[]" type="checkbox" value="<?php echo $banner['id'];?>">
                            標題：<?php echo $banner['title'];?>&nbsp;&nbsp;
                            <a style="color:#000000" href="banner_edit.php?banner=<?php echo $banner['id'];?>">修改</a>
                    </td>
                  </tr>
                </table>
    <?php } ?>

                <table border="0" cellpadding="0" cellspacing="0" class="m-text-2-con">
                  <tr> 
                    <td width="250" height="30">
                        <input type="checkbox" id="chk_all" />
                        選擇本頁顯示的所有訊息
                    </td>
                    <td>
                        <input name="submit" type='submit' value='刪除選擇的訊息' />
                    </td>
                  </tr>
              </table>

            </form>


        </div>
		
      </div>

    </div>
  </div>
</div>

      <div id="botton"><div id="copyright"><table border="0" cellpadding="0" cellspacing="0" class="copy">
  <tr>
    <td>© COPYRIGHTS 2010 INC. APARTMENT STUDIO All rights reserved.</td>
  </tr>
</table>
</div></div>
</body>
</html>
